<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>OA协同办公系统</title>
<link href="css/table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script type="text/javascript" src="js/file.js"></script>
<style type="text/css">
.ulemail{ list-style:none; margin:0;}
.ulemail li{ font-size:12px; color:#8fa1af}
.ulxz{list-style:none; margin:5px 0 0 0}
.ulxz li{float:left; margin:0}
.tdtytie{text-align: center;}
tr,td{background: #ffffff}
</style>
<script type="text/javascript">
function loadFile(val){
	var fileId=$("#fileArray").val();
	if(fileId!=''&&fileId!='null'){
		var param={"fileArray":fileId};
		$.post("getFileList.action",param,function(data) {
			var list=data.fileList;
			for(var i=0;i<list.length;i++){
				$("#"+val).prepend("<li>"+list[i].name+"&nbsp;<a href=\"downLoadFile.action?fileId="+list[i].id+"\">下载</a></li>");
	        }
		},"json");
	}
}

function opinionReoly(){
	var reportid = $("#reportId").val();
	var param={"reportId":reportid};
	$.post("opinionReoly.action",param,function(data){
		var list = data.opinionList;
		if(list.length>0){
		var info="<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\" bordercolor=\"#999999\" bgcolor=\"#999999\" ><tr><td class=\"bgcolor5\" align=\"center\" height=\"17px\" >批示意见</td></tr>";
		for(var i=0; i < list.length; i++){
			info+="<tr><td align=\"left\">"+list[i].content;
			info+="<div align=\"right\"><br/>"+list[i].userName+"&nbsp;"+(list[i].addTime.year-100+2000)+"-"+(list[i].addTime.month+1)+"-"+(list[i].addTime.date)+"</div></td></tr>";
		}
		info+="</table>";
		$("#opinion").html(info);
		}
	},"json");
}

window.onload=function(){
	loadFile('filetable');
	opinionReoly();
}
	
window.onbeforeunload=function(){
    if (window.event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey){
       window.opener.location.reload();
    }else{
    	window.opener.location.reload();
    }
} 

function selectUser(){
		var url="getGrouphome.action";
		openWindow(url,700,400);
}

function getOldValue(){
	  var array = document.getElementById("array").value;
	  return array;
	}
	
function setValue(value){
	  document.getElementById("array").value = value;
	  var arr = eval(value);
	  var names = "";
	  var ids = "";
	  for(i=0;i<arr.length;i++){
	    ids =  ids + "," + arr[i].value;
	    names = names + "," + arr[i].name;
	  }
	  if(names.length>0){
	    names = names.substring(1);
	    ids =  ids.substring(1);
	  }
	  document.getElementById("names").value=names;
	  document.getElementById("ids").value=ids;
	}
	
function saveReportOpinion(){
	var content =$("#content").val();
	if(content=='null'||content==''){
		alert("请填写您的意见");
		return;
	}
	document.reportLookForm.submit();
	window.close();
}
</script>
</head>
<body>
<input type="hidden" id="fileArray" value="${oMyReports.fileId}">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
  <tbody>
  <tr>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
    <td style="background: url('image/wsoa_window_002.gif');"><table border="0" cellpadding="0" cellspacing="0">
      <tbody><tr>
        <td align="center" style="background: url('image/wsoa_window_002.gif');" width="10"><img src="image/center_19.gif"></td>
        <td align="center" style="background: url('image/wsoa_window_002.gif');"></td>
        <td></td>
        </tr>
    </tbody>
    </table></td>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
  </tr>
  <tr>
    <td style="background: url('image/wsoa_window_010.gif');"  width="1">&nbsp;</td>
    <td>
    <form method="post" name="reportLookForm" id="reportLook" action="saveReportOpinion.action">
	<table class="table5" style="width:100%;margin: 10px 0px 10px 0px;height: 400px" align="center">
		<tr>
			<td width="80px" class="table5 bgcolor5 tdtytie">汇报日期：</td>
			<td class="table5" width="200px"><fmt:formatDate value="${oMyReports.reportingDate}" type="date"/></td>
			<td class="table5 bgcolor5 tdtytie" width="50px">类型：</td>
			<td class="table5" width="100px">${oMyReports.type }</td>
			<td class="table5 bgcolor5 tdtytie" width="50px">模板：</td>
			<td class="table5">${oMyReports.templateName}</td>
		</tr>
		<tr><td class="table5 bgcolor5 tdtytie">附件：</td><td class="table5" colspan="5">
			<ul class="ulxz" id="filetable">
                
            </ul>
		</td></tr>
		<tr>
			<td class="table5 bgcolor5 tdtytie">汇报内容：</td><td class="table5" colspan="5">${oMyReports.content }</td>
		</tr>
		<tr>
			<td class="table5 bgcolor5 tdtytie">备注：</td><td class="table5" colspan="5">${oMyReports.note }</td>
		</tr>
		<tr>
			<td class="table5 bgcolor5 tdtytie">批示意见：</td>
			<td class="table5" valign="top" colspan="5" id="opinion">
				
			</td>
		</tr>
		<input type="hidden" id="array" >
		<input type="hidden" value="${oMyReports.id }" name="reportId" id="reportId">
		<tr><td class="table5 bgcolor5 tdtytie">填写意见：</td>
		<td class="table5" colspan="5">
			<textarea name="content" id="content" onpropertychange="if(this.value.length>100){this.value=this.value.substr(0,100)}" title="最多不超过100个字符" style="width: 99%;height: 40px;" ></textarea>
		</td></tr>
		<tr><td class="table5 bgcolor5 tdtytie">提交至：</td>
		<td class="table5" colspan="5">
			<textarea readonly="readonly" id="names" name="names" style="width:99%;height:40px;">${names }</textarea><br/>
			<input type="hidden" id="ids" name="users" value="${users}">
			<a href="javascript:selectUser()">添加用户</a>
		</td></tr>
		<tr><td class="table5" align="center" colspan="6"><input onclick="saveReportOpinion()" class="button_04" type="button" value="保存退出" />&nbsp;<input class="button_02" type="reset" value="重置" />&nbsp;<input class="button_02" type="button" value="退出" onclick="window.close();"/></td></tr>
		
	</table>
	</form>
     </td>
<td style="background: url('image/wsoa_window_006.gif');"  width="1">&nbsp;</td></tr>
  <tr>
    <td height="1" width="1"><img src="image/wsoa_window_009.gif" height="16" width="14"></td>
    <td style="background: url('image/wsoa_window_008.gif');" height="1"></td>
    <td height="1" width="1"><img src="image/wsoa_window_007.gif" height="16" width="12"></td>
  </tr>
</tbody>
</table>
</body>
</html>